<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>









 
 
 

  
  
  




  
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
    
<meta http-equiv="content-type" content="text/html; charset=utf-8"><title>OpenSocial API Developer's Guide (v0.7) - OpenSocial - Google Code</title>

<script type="text/javascript">
(function(){function a(){this.t={};this.tick=function(c){this.t[c]=(new Date).getTime()};this.tick("start")}var b=new a;window.jstiming={Timer:a,load:b};if(window.external&&window.external.pageT)window.jstiming.pt=window.external.pageT;})();

var _tocPath_ = '/html/apis/opensocial/docs/_toc.ezt';
</script>
<link href="devguide_files/codesite.css" type="text/css" rel="stylesheet">
<script src="devguide_files/codesite.js" type="text/javascript"></script>
<link rel="search" type="application/opensearchdescription+xml" title="Google Code" href="http://code.google.com/osd.xml"><!--[if IE]><link rel="stylesheet" type="text/css" href="/css/iehacks.css" /><![endif]-->



  <link rel="stylesheet" type="text/css" href="devguide_files/semantic_headers.css">

  <style type="text/css">
  img.centered {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1em;
    border: 1px solid #aaa;
  }
  .changed {
    font: 10px Arial, sans-serif;
    color: #ff0000;
  }
  .pretag {
    margin-bottom: -1em;
    margin-top: 1em;
  }
  </style></head><body class="gc-documentation">

    
    
    <div id="gc-container">
<a name="top"></a>
<div id="skipto">
  <a href="#gc-pagecontent">Skip to page content</a>
  <a href="#gc-toc">Skip to main navigation</a>
</div>
<div id="langpref">    
   <a style="text-decoration: none; cursor: pointer;" class="dropdown" href="http://code.google.com/"><span class="title1219980599640" style="text-decoration: underline;">English</span><span style="vertical-align: middle; text-decoration: none; font-family: arial,sans-serif; font-size: 11px;">&nbsp;▼</span></a>
   <span>|</span>
   <a href="http://code.google.com/more/">Site Directory</a>
</div>
<div id="gc-header">
  <div id="logo"><a href="http://code.google.com/">
  
     <img src="devguide_files/cleardot.gif" alt="Google Code Home Page" id="gc-logo-img" height="1" width="1">
  
  </a></div>
  <div id="search">
    <div id="searchForm" class="searchForm" style="">
      <form action="" accept-charset="utf-8" class="gsc-search-box" onsubmit="executeGSearch(document.getElementById('gsearchInput').value); return false;">
        <table class="gsc-search-box" cellpadding="0" cellspacing="0">
          <tbody>
            <tr>
              <td class="gsc-input">
                <input id="gsearchInput" name="q" maxlength="2048" class="gsc-input" autocomplete="off" title="Google Code Search" style="width: 345px;" type="text">
              </td>
              <td class="gsc-search-button">
                <div id="cs-searchresults" onclick="event.cancelBubble = true;"></div>
                <input title="Search" id="gsearchButton" class="gsc-search-button" value="Search" type="submit">
              </td>
            </tr>
            <tr>
              <td class="greytext">e.g. "ajax apis" or "open source"</td>
            </tr>
          </tbody>
        </table>
      </form>
    </div> <!-- end searchForm -->
    <div id="searchForm2" class="searchForm2" style="display: none;">
      <form id="cse" action="http://www.google.com/cse">
        <input name="cref" value="http://code.google.com/cse/googlecode-context.xml" type="hidden">
        <input name="q" maxlength="2048" autocomplete="off" title="Google Code Search" style="width: 345px;" type="text">
        <input name="sa" value="Search" title="Search" type="submit"><br>
        <div class="greytext">e.g. "ajax apis" or "open source"</div>
      </form>
    </div> <!-- end searchForm2 -->
  </div> <!-- end search -->
</div> <!-- end gc-header -->


<div id="codesiteContent">

<a name="gc-topnav-anchor"></a>
<div id="gc-topnav">
  <h1>OpenSocial</h1>
  <ul id="docs" class="gc-topnav-tabs">

    <li id="home_link">
      <a href="http://code.google.com/apis/opensocial/" title="OpenSocial home page">Home</a>
    </li>
  
    <li id="docs_link">
      <a href="http://code.google.com/apis/opensocial/docs/index.html" class="selected" title="Official OpenSocial documentation">Docs</a>
    </li>
  
    <li id="faq_link">
      <a href="http://code.google.com/apis/opensocial/faq.html" title="Answers to frequently asked questions about OpenSocial">FAQ</a>
    </li>
  
    <li id="articles_link">
      <a href="http://code.google.com/apis/opensocial/articles/" title="Focused articles and tutorials for OpenSocial developers">Articles</a>
    </li>
  
    <li>
      <a href="http://opensocialapis.blogspot.com/" title="Official OpenSocial blog">Blog</a>
    </li>
  
    <li>
      <a href="http://groups.google.com/group/opensocial" title="OpenSocial developer forum">Group</a>
    </li>
  
    <li>
      <a href="http://code.google.com/apis/opensocial/terms.html" title="OpenSocial terms of service">Terms</a>
    </li>
  

  </ul>
</div> <!-- end gc-topnav -->

    <div class="g-section g-tpl-210">

      <a name="gc-toc"></a>  
      <div class="g-unit g-first" id="gc-toc">
          <ul class="treelist tlw-nested-only tlw-processed tlw-instance-0">
    <li><a href="http://code.google.com/apis/opensocial/partners.html">Who's Using It?</a></li>
    <li><a href="http://code.google.com/apis/opensocial/gettingstarted.html">Building Social Apps</a></li>
    <li><a href="http://code.google.com/apis/opensocial/container.html">Hosting OpenSocial Apps</a></li>
  </ul>

<div class="line"></div>

<ul class="treelist tlw-nested-only tlw-processed tlw-instance-1">
  <li><h1 class="tlw-ignore">JavaScript API</h1>
    <ul>
      <li class="selected"><a href="http://code.google.com/apis/opensocial/docs/0.7/devguide.html">Developer's Guide (v0.7)</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/releasenotes.html">Release Notes (v0.8)</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/spec.html">API Specification (v0.8)</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand API Reference (v0.8)"><img src="devguide_files/cleardot.gif" alt="Expand API Reference (v0.8)" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/">API Reference (v0.8)</a></div><ul style="display: none;" id="1-sub-0">
     <!-- _sidenav.ezt doesn't work with the current scripts. Shakila is working on it. -->
      
<ul>
<li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand opensocial"><img src="devguide_files/cleardot.gif" alt="Expand opensocial" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial">opensocial</a></div><ul style="display: none;" id="1-sub-1">
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Activity"><img src="devguide_files/cleardot.gif" alt="Expand Activity" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Activity">Activity</a></div><ul style="display: none;" id="1-sub-2">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Activity.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Address"><img src="devguide_files/cleardot.gif" alt="Expand Address" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Address">Address</a></div><ul style="display: none;" id="1-sub-3">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Address.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand BodyType"><img src="devguide_files/cleardot.gif" alt="Expand BodyType" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.BodyType">BodyType</a></div><ul style="display: none;" id="1-sub-4">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.BodyType.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Collection">Collection</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.CreateActivityPriority">CreateActivityPriority</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand DataRequest"><img src="devguide_files/cleardot.gif" alt="Expand DataRequest" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest">DataRequest</a></div><ul style="display: none;" id="1-sub-5">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.DataRequestFields">DataRequestFields</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.FilterType">FilterType</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.PeopleRequestFields">PeopleRequestFields</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.SortOrder">SortOrder</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.DataResponse">DataResponse</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Email"><img src="devguide_files/cleardot.gif" alt="Expand Email" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Email">Email</a></div><ul style="display: none;" id="1-sub-6">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Email.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Enum"><img src="devguide_files/cleardot.gif" alt="Expand Enum" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum">Enum</a></div><ul style="display: none;" id="1-sub-7">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum.Drinker">Drinker</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum.Gender">Gender</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum.LookingFor">LookingFor</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum.Presence">Presence</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Enum.Smoker">Smoker</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Environment"><img src="devguide_files/cleardot.gif" alt="Expand Environment" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Environment">Environment</a></div><ul style="display: none;" id="1-sub-8">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Environment.ObjectType">ObjectType</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.EscapeType">EscapeType</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand IdSpec"><img src="devguide_files/cleardot.gif" alt="Expand IdSpec" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.IdSpec">IdSpec</a></div><ul style="display: none;" id="1-sub-9">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.IdSpec.Field">Field</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.IdSpec.PersonId">PersonId</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand MediaItem"><img src="devguide_files/cleardot.gif" alt="Expand MediaItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.MediaItem">MediaItem</a></div><ul style="display: none;" id="1-sub-10">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.MediaItem.Field">Field</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.MediaItem.Type">Type</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Message"><img src="devguide_files/cleardot.gif" alt="Expand Message" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Message">Message</a></div><ul style="display: none;" id="1-sub-11">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Message.Field">Field</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Message.Type">Type</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Name"><img src="devguide_files/cleardot.gif" alt="Expand Name" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Name">Name</a></div><ul style="display: none;" id="1-sub-12">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Name.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand NavigationParameters"><img src="devguide_files/cleardot.gif" alt="Expand NavigationParameters" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.NavigationParameters">NavigationParameters</a></div><ul style="display: none;" id="1-sub-13">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.NavigationParameters.DestinationType">DestinationType</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.NavigationParameters.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Organization"><img src="devguide_files/cleardot.gif" alt="Expand Organization" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Organization">Organization</a></div><ul style="display: none;" id="1-sub-14">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Organization.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Permission">Permission</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Person"><img src="devguide_files/cleardot.gif" alt="Expand Person" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Person">Person</a></div><ul style="display: none;" id="1-sub-15">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Person.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Phone"><img src="devguide_files/cleardot.gif" alt="Expand Phone" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Phone">Phone</a></div><ul style="display: none;" id="1-sub-16">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Phone.Field">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand ResponseItem"><img src="devguide_files/cleardot.gif" alt="Expand ResponseItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.ResponseItem">ResponseItem</a></div><ul style="display: none;" id="1-sub-17">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.ResponseItem.Error">Error</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Url"><img src="devguide_files/cleardot.gif" alt="Expand Url" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Url">Url</a></div><ul style="display: none;" id="1-sub-18">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Url.Field">Field</a>
  </li>
</ul>
  </li>
</ul>
</li>
</ul>

 

     <!-- Until that's fixed, we include _all_classes.ezt instead. -->
     <!--    
<ul>
<li><a href="#opensocial">opensocial</a>
<ul>
  <li><a href="#opensocial.Activity">Activity</a>
<ul>
  <li><a href="#opensocial.Activity.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Address">Address</a>
<ul>
  <li><a href="#opensocial.Address.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.BodyType">BodyType</a>
<ul>
  <li><a href="#opensocial.BodyType.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Collection">Collection</a>
  </li>
  <li><a href="#opensocial.CreateActivityPriority">CreateActivityPriority</a>
  </li>
  <li><a href="#opensocial.DataRequest">DataRequest</a>
<ul>
  <li><a href="#opensocial.DataRequest.DataRequestFields">DataRequestFields</a>
  </li>
  <li><a href="#opensocial.DataRequest.FilterType">FilterType</a>
  </li>
  <li><a href="#opensocial.DataRequest.PeopleRequestFields">PeopleRequestFields</a>
  </li>
  <li><a href="#opensocial.DataRequest.SortOrder">SortOrder</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.DataResponse">DataResponse</a>
  </li>
  <li><a href="#opensocial.Email">Email</a>
<ul>
  <li><a href="#opensocial.Email.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Enum">Enum</a>
<ul>
  <li><a href="#opensocial.Enum.Drinker">Drinker</a>
  </li>
  <li><a href="#opensocial.Enum.Gender">Gender</a>
  </li>
  <li><a href="#opensocial.Enum.LookingFor">LookingFor</a>
  </li>
  <li><a href="#opensocial.Enum.Presence">Presence</a>
  </li>
  <li><a href="#opensocial.Enum.Smoker">Smoker</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Environment">Environment</a>
<ul>
  <li><a href="#opensocial.Environment.ObjectType">ObjectType</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.EscapeType">EscapeType</a>
  </li>
  <li><a href="#opensocial.IdSpec">IdSpec</a>
<ul>
  <li><a href="#opensocial.IdSpec.Field">Field</a>
  </li>
  <li><a href="#opensocial.IdSpec.PersonId">PersonId</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.MediaItem">MediaItem</a>
<ul>
  <li><a href="#opensocial.MediaItem.Field">Field</a>
  </li>
  <li><a href="#opensocial.MediaItem.Type">Type</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Message">Message</a>
<ul>
  <li><a href="#opensocial.Message.Field">Field</a>
  </li>
  <li><a href="#opensocial.Message.Type">Type</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Name">Name</a>
<ul>
  <li><a href="#opensocial.Name.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.NavigationParameters">NavigationParameters</a>
<ul>
  <li><a href="#opensocial.NavigationParameters.DestinationType">DestinationType</a>
  </li>
  <li><a href="#opensocial.NavigationParameters.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Organization">Organization</a>
<ul>
  <li><a href="#opensocial.Organization.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Permission">Permission</a>
  </li>
  <li><a href="#opensocial.Person">Person</a>
<ul>
  <li><a href="#opensocial.Person.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Phone">Phone</a>
<ul>
  <li><a href="#opensocial.Phone.Field">Field</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.ResponseItem">ResponseItem</a>
<ul>
  <li><a href="#opensocial.ResponseItem.Error">Error</a>
  </li>
</ul>
  </li>
  <li><a href="#opensocial.Url">Url</a>
<ul>
  <li><a href="#opensocial.Url.Field">Field</a>
  </li>
</ul>
  </li>
</ul>
</li>
</ul>

 -->

     <!-- The following line is obsolete because (a) we don't include _all_classes.ezt -->
     <!-- any more, and (b) the extra tag in _all_classes.ezt has been fixed anyway. -->
     <!--     </ul></li>  -->
          <li style="padding-top: 0pt; padding-bottom: 0pt;"> 
              <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand gadgets (core)"><img src="devguide_files/cleardot.gif" alt="Expand gadgets (core)" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#core">gadgets (core)</a></div><ul style="display: none;" id="1-sub-19">
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.Prefs">Prefs</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand io"><img src="devguide_files/cleardot.gif" alt="Expand io" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io">io</a></div><ul style="display: none;" id="1-sub-20">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io.AuthorizationType">AuthorizationType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io.ContentType">ContentType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io.MethodType">MethodType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io.ProxyUrlRequestParameters">ProxyUrlRequestParameters</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.io.RequestParameters">RequestParameters</a></li>
        </ul>
      </li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.json">json</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.util">util</a></li>
    </ul>


          </li>
          <li style="padding-top: 0pt; padding-bottom: 0pt;"> 
              <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand gadgets (feature-specific)"><img src="devguide_files/cleardot.gif" alt="Expand gadgets (feature-specific)" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#features">gadgets (feature-specific)</a></div><ul style="display: none;" id="1-sub-21">
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.MiniMessage">MiniMessage</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.Tab">Tab</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.TabSet">TabSet</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.flash">flash</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.pubsub">pubsub</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.rpc">rpc</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;"> <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand skins"><img src="devguide_files/cleardot.gif" alt="Expand skins" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.skins">skins</a></div><ul style="display: none;" id="1-sub-22">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.skins.Property">Property</a></li>
      </ul></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;"> <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand views"><img src="devguide_files/cleardot.gif" alt="Expand views" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.views">views</a></div><ul style="display: none;" id="1-sub-23">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.views.View">View</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.views.ViewType">ViewType</a></li>
      </ul></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/reference/gadgets/#gadgets.window">window</a></li>
    </ul>

          </li>
        </ul>
      </li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Collapse Previous Versions"><img src="devguide_files/cleardot.gif" alt="Collapse Previous Versions" class="tlw-control tlw-minus"></a><span class="tlw-title">Previous Versions</span></div><ul style="display: block;" id="1-sub-62">
        <li style="padding-top: 0pt; padding-bottom: 0pt;">
          <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Collapse Version 0.7"><img src="devguide_files/cleardot.gif" alt="Collapse Version 0.7" class="tlw-control tlw-minus"></a><span class="tlw-title">Version 0.7</span></div><ul style="display: block;" id="1-sub-63">
            <li class="selected"><a href="http://code.google.com/apis/opensocial/docs/0.7/devguide.html">Developer's Guide</a></li>
            <li><a href="http://code.google.com/apis/opensocial/docs/0.7/spec.html">API Specification</a></li>
            <li style="padding-top: 0pt; padding-bottom: 0pt;">
              <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand API Reference"><img src="devguide_files/cleardot.gif" alt="Expand API Reference" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/">API Reference</a></div><ul style="display: none;" id="1-sub-24">
                


<li style="padding-top: 0pt; padding-bottom: 0pt;">
  <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand opensocial"><img src="devguide_files/cleardot.gif" alt="Expand opensocial" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.html">opensocial</a></div><ul style="display: none;" id="1-sub-25">
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Activity"><img src="devguide_files/cleardot.gif" alt="Expand Activity" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.html">Activity</a></div><ul style="display: none;" id="1-sub-26">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.Field.html">Field</a></li>
        <li style="padding-top: 0pt; padding-bottom: 0pt;">
          <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand MediaItem"><img src="devguide_files/cleardot.gif" alt="Expand MediaItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.MediaItem.html">MediaItem</a></div><ul style="display: none;" id="1-sub-27">
            <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.MediaItem.Field.html">Field</a></li>
            <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.MediaItem.Type.html">Type</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Address"><img src="devguide_files/cleardot.gif" alt="Expand Address" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Address.html">Address</a></div><ul style="display: none;" id="1-sub-28">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Address.Field.html">Field</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand BodyType"><img src="devguide_files/cleardot.gif" alt="Expand BodyType" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.BodyType.html">BodyType</a></div><ul style="display: none;" id="1-sub-29">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.BodyType.Field.html">Field</a></li>
      </ul>
    </li>
    <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Collection.html">Collection</a></li>
    <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.CreateActivityPriority.html">CreateActivityPriority</a></li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand DataRequest"><img src="devguide_files/cleardot.gif" alt="Expand DataRequest" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.html">DataRequest</a></div><ul style="display: none;" id="1-sub-30">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.FilterType.html">FilterType</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.Group.html">Group</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.PeopleRequestFields.html">PeopleRequestFields</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.PersonId.html">PersonId</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataRequest.SortOrder.html">SortOrder</a></li>
      </ul>
    </li>
    <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.DataResponse.html">DataResponse</a></li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Email"><img src="devguide_files/cleardot.gif" alt="Expand Email" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Email.html">Email</a></div><ul style="display: none;" id="1-sub-31">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Email.Field.html">Field</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Enum"><img src="devguide_files/cleardot.gif" alt="Expand Enum" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Enum.html">Enum</a></div><ul style="display: none;" id="1-sub-32">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Enum.Drinker.html">Drinker</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Enum.Gender.html">Gender</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Enum.Smoker.html">Smoker</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Environment"><img src="devguide_files/cleardot.gif" alt="Expand Environment" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Environment.html">Environment</a></div><ul style="display: none;" id="1-sub-33">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Environment.ObjectType.html">ObjectType</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Message"><img src="devguide_files/cleardot.gif" alt="Expand Message" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Message.html">Message</a></div><ul style="display: none;" id="1-sub-34">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Message.Field.html">Field</a></li>
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Message.Type.html">Type</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Name"><img src="devguide_files/cleardot.gif" alt="Expand Name" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Name.html">Name</a></div><ul style="display: none;" id="1-sub-35">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Name.Field.html">Field</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Organization"><img src="devguide_files/cleardot.gif" alt="Expand Organization" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Organization.html">Organization</a></div><ul style="display: none;" id="1-sub-36">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Organization.Field.html">Field</a></li>
      </ul>
    </li>
    <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Permission.html">Permission</a></li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Person"><img src="devguide_files/cleardot.gif" alt="Expand Person" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Person.html">Person</a></div><ul style="display: none;" id="1-sub-37">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Person.Field.html">Field</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Phone"><img src="devguide_files/cleardot.gif" alt="Expand Phone" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Phone.html">Phone</a></div><ul style="display: none;" id="1-sub-38">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Phone.Field.html">Field</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand ResponseItem"><img src="devguide_files/cleardot.gif" alt="Expand ResponseItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.ResponseItem.html">ResponseItem</a></div><ul style="display: none;" id="1-sub-39">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.ResponseItem.Error.html">Error</a></li>
      </ul>
    </li>
    <li style="padding-top: 0pt; padding-bottom: 0pt;">
      <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Url"><img src="devguide_files/cleardot.gif" alt="Expand Url" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Url.html">Url</a></div><ul style="display: none;" id="1-sub-40">
        <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Url.Field.html">Field</a></li>
      </ul>
    </li>
  </ul>
</li>

                  <li style="padding-top: 0pt; padding-bottom: 0pt;">
    <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand gadgets (core)"><img src="devguide_files/cleardot.gif" alt="Expand gadgets (core)" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets_core.html">gadgets (core)</a></div><ul style="display: none;" id="1-sub-41">
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.Prefs.html">Prefs</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand io"><img src="devguide_files/cleardot.gif" alt="Expand io" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.io.html">io</a></div><ul style="display: none;" id="1-sub-42">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.io.AuthorizationType.html">AuthorizationType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.io.ContentType.html">ContentType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.io.MethodType.html">MethodType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.io.RequestParameters.html">RequestParameters</a></li>
        </ul>
      </li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.json.html">json</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.util.html">util</a></li>
    </ul>
  </li>

                  <li style="padding-top: 0pt; padding-bottom: 0pt;">
    <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand gadgets (feature-specific)"><img src="devguide_files/cleardot.gif" alt="Expand gadgets (feature-specific)" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets_feature.html">gadgets (feature-specific)</a></div><ul style="display: none;" id="1-sub-43">
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.MiniMessage.html">MiniMessage</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.Tab.html">Tab</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.TabSet.html">TabSet</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.flash.html">flash</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.rpc.html">rpc</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand views"><img src="devguide_files/cleardot.gif" alt="Expand views" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.views.html">views</a></div><ul style="display: none;" id="1-sub-44">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.views.View.html">View</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.views.ViewType.html">ViewType</a></li>
        </ul>
      </li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand skins"><img src="devguide_files/cleardot.gif" alt="Expand skins" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.skins.html">skins</a></div><ul style="display: none;" id="1-sub-45">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.skins.Property.html">Property</a></li>
        </ul>
      </li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.window.html">window</a></li>
    </ul>
  </li>

              </ul>
            </li>
          </ul>
        </li>
        <li style="padding-top: 0pt; padding-bottom: 0pt;">
          <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Version 0.6"><img src="devguide_files/cleardot.gif" alt="Expand Version 0.6" class="tlw-control tlw-plus"></a><span class="tlw-title">Version 0.6</span></div><ul style="display: none;" id="1-sub-64">
            <li><a href="http://code.google.com/apis/opensocial/docs/0.6/devguide.html">Developer's Guide</a></li>
            <li><a href="http://code.google.com/apis/opensocial/docs/0.6/spec.html">API Specification</a></li>
            <li style="padding-top: 0pt; padding-bottom: 0pt;">
              
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand API Reference"><img src="devguide_files/cleardot.gif" alt="Expand API Reference" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/">API Reference</a></div><ul style="display: none;" id="1-sub-46">    
 <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand opensocial"><img src="devguide_files/cleardot.gif" alt="Expand opensocial" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.html">opensocial</a></div><ul style="display: none;" id="1-sub-47">
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Activity"><img src="devguide_files/cleardot.gif" alt="Expand Activity" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Activity.html">Activity</a></div><ul style="display: none;" id="1-sub-48">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Activity.Field.html">Field</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand MediaItem"><img src="devguide_files/cleardot.gif" alt="Expand MediaItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Activity.MediaItem.html">MediaItem</a></div><ul style="display: none;" id="1-sub-49">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Activity.MediaItem.Field.html">Field</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Activity.MediaItem.Type.html">Type</a>
  </li>
</ul>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Collection.html">Collection</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand ContentRequestParameters"><img src="devguide_files/cleardot.gif" alt="Expand ContentRequestParameters" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ContentRequestParameters.html">ContentRequestParameters</a></div><ul style="display: none;" id="1-sub-50">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ContentRequestParameters.AuthenticationType.html">AuthenticationType</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ContentRequestParameters.ContentType.html">ContentType</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ContentRequestParameters.MethodType.html">MethodType</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.CreateActivityPriority.html">CreateActivityPriority</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand DataRequest"><img src="devguide_files/cleardot.gif" alt="Expand DataRequest" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.html">DataRequest</a></div><ul style="display: none;" id="1-sub-51">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.ActivityRequestFields.html">ActivityRequestFields</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.FilterType.html">FilterType</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.Group.html">Group</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.PeopleRequestFields.html">PeopleRequestFields</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.PersonId.html">PersonId</a>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataRequest.SortOrder.html">SortOrder</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.DataResponse.html">DataResponse</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Environment"><img src="devguide_files/cleardot.gif" alt="Expand Environment" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Environment.html">Environment</a></div><ul style="display: none;" id="1-sub-52">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Environment.ObjectType.html">ObjectType</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Permission.html">Permission</a>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Person"><img src="devguide_files/cleardot.gif" alt="Expand Person" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Person.html">Person</a></div><ul style="display: none;" id="1-sub-53">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Person.Field.html">Field</a>
  </li>
</ul>
  </li>
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand ResponseItem"><img src="devguide_files/cleardot.gif" alt="Expand ResponseItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ResponseItem.html">ResponseItem</a></div><ul style="display: none;" id="1-sub-54">
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.ResponseItem.Error.html">Error</a>
  </li>
</ul>
  </li>
  <li><a href="http://code.google.com/apis/opensocial/docs/0.6/reference/opensocial.Surface.html">Surface</a>
  </li>
</ul>
</li>

</ul>


            </li>
          </ul>
        </li>
          <li style="padding-top: 0pt; padding-bottom: 0pt;">
            <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Version 0.5"><img src="devguide_files/cleardot.gif" alt="Expand Version 0.5" class="tlw-control tlw-plus"></a><span class="tlw-title">Version 0.5</span></div><ul style="display: none;" id="1-sub-65">
              <li><a href="http://code.google.com/apis/opensocial/docs/0.5/devguide.html">Developer's Guide</a></li>
              <li style="padding-top: 0pt; padding-bottom: 0pt;">
                
<div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand API Reference"><img src="devguide_files/cleardot.gif" alt="Expand API Reference" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/">API Reference</a></div><ul style="display: none;" id="1-sub-55">
  <li style="padding-top: 0pt; padding-bottom: 0pt;">
    <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand opensocial"><img src="devguide_files/cleardot.gif" alt="Expand opensocial" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.html">opensocial</a></div><ul style="display: none;" id="1-sub-56">
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Activity"><img src="devguide_files/cleardot.gif" alt="Expand Activity" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Activity.html">Activity</a></div><ul style="display: none;" id="1-sub-57">
	        <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Activity.Field.html">Field</a></li>
	        <li style="padding-top: 0pt; padding-bottom: 0pt;">
	          <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand MediaItem"><img src="devguide_files/cleardot.gif" alt="Expand MediaItem" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Activity.MediaItem.html">MediaItem</a></div><ul style="display: none;" id="1-sub-58">
              <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Activity.MediaItem.Field.html">Field</a></li>
              <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Activity.MediaItem.Type.html">Type</a></li>
            </ul> 
          </li> <!-- end MediaItem -->
        </ul>
      </li> <!-- end Activity -->
      <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Collection.html">Collection</a></li>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.CreateActivityPriority.html">CreateActivityPriority</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand DataRequest"><img src="devguide_files/cleardot.gif" alt="Expand DataRequest" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.html">DataRequest</a></div><ul style="display: none;" id="1-sub-59">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.ActivityRequestFields.html">ActivityRequestFields</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.FilterType.html">FilterType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.Group.html">Group</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.PeopleRequestFields.html">PeopleRequestFields</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.PersonId.html">PersonId</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.ProfileDetailType.html">ProfileDetailType</a></li>
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataRequest.SortOrder.html">SortOrder</a></li>
        </ul> 
      </li> <!-- End DataRequest -->
      <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.DataResponse.html">DataResponse</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Person"><img src="devguide_files/cleardot.gif" alt="Expand Person" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Person.html">Person</a></div><ul style="display: none;" id="1-sub-60">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Person.Field.html">Field</a></li>
        </ul>
      </li> <!-- end Person -->
      <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.ResponseItem.html">ResponseItem</a></li>
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="javascript:void(0)" class="tlw-control" title="Expand Stream"><img src="devguide_files/cleardot.gif" alt="Expand Stream" class="tlw-control tlw-plus"></a><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Stream.html">Stream</a></div><ul style="display: none;" id="1-sub-61">
          <li><a href="http://code.google.com/apis/opensocial/docs/0.5/reference/opensocial.Stream.Field.html">Field</a></li>
        </ul>
      </li> <!-- end Stream -->
    </ul>
  </li> <!-- end opensocial -->
</ul>


              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </li>
  <li><h1 class="tlw-ignore">RESTful API</h1>
    <ul>
      <li><a href="http://code.google.com/apis/opensocial/docs/0.8/restfulspec.html">RESTful API Specification</a></li>
    </ul>
  </li>
  <li><h1 class="tlw-ignore">Other Resources</h1>
    <ul>
      <li><a href="http://code.google.com/apis/orkut/">Build apps for Orkut</a></li>
      <li><a href="http://code.google.com/apis/gadgets/docs/spec.html">Gadgets Specification</a></li>
    </ul>
  </li>
</ul>

      </div>
      
      <a name="gc-pagecontent"></a>   
      <div style="position: relative;" class="g-unit" id="gc-pagecontent"><ol class="cs-breadcrumbs"><li class="cs-crumb"><a href="http://code.google.com/apis/opensocial/docs/index.html" class="" title="Official OpenSocial documentation">Docs</a><span class="cs-crumbSpacer">&nbsp;&gt;&nbsp;</span></li><li class="cs-crumb"><a href="http://code.google.com/apis/opensocial/docs/0.7/devguide.html">Developer's Guide (v0.7)</a><span class="cs-crumbSpacer">&nbsp;&gt;&nbsp;</span></li><li class="cs-crumb"><a href="http://code.google.com/apis/opensocial/docs/0.7/devguide.html">Developer's Guide</a></li></ol>
        <h1 class="page_title">OpenSocial API Developer's Guide (v0.7)</h1>
<p>
  
  
  
  <!-- ########## PAGE CONTENT ########## -->
  
    

</p><p>This guide will help you build OpenSocial applications. It is meant for developers who have some general familiarity with
the <a href="http://code.google.com/apis/gadgets/">Gadgets API</a>, and 
JavaScript, but provides links to other resources in places where you 
may need more information.</p>
<p>This document has been modified to reflect changes from the 0.7 
  update of the OpenSocial API. Sections are marked as being <sup class="changed">New!</sup> or <sup class="changed">Updated</sup> to help you identify coding practices that have
  changed since the last version.</p>
<h2>Contents</h2>
    <ol class="toc">
      <li><a href="#Writing">Writing a Social Application </a></li>            
      <li><a href="#Importing">Importing the OpenSocial Library </a></li>
      <li><a href="#ListFriends_Intro">Accessing People and Profiles</a>
      <ol class="toc">
          <li><a href="#Basic_Info">Getting Basic Information </a></li>
          <li><a href="#ListFriends_Complete">Complete Code for List Friends</a></li>
      </ol>
      </li>
      <li><a href="#Persistent">Working with Persistent Data</a></li>
      <li><a href="#Activities">Posting Activities</a></li>
      <li><a href="#Container">Interacting with the Container</a>
      <ol>
          <li><a href="#Nav">Navigating from One View to Another</a></li>
          <li><a href="#Env">Querying the Environment</a></li>
          <li><a href="#Multiple_Content">Including Multiple Content Sections</a> </li>
      </ol>
      </li>
      <li><a href="#Remote_Content">Fetching Remote Content</a>
      <ol>
          <li><a href="#Caching">Caching</a></li>
          <li><a href="#XML">XML Example</a></li>
          <li><a href="#JSON">JSON Example</a></li>
          <li><a href="#POST">Using the POST Method</a></li>
          <li><a href="#Auth">Setting an Authorization Type</a>  </li>
      </ol>
      </li>
      <li><a href="#Permission">Permission Control</a> </li>
      <li><a href="#Learn">To Learn More </a>  </li>
    </ol>

    <a name="Writing" id="Writing"></a>
    <h2>Writing a Social Application </h2>
    <p>A social application is simply a application that runs on a container that supports
    the OpenSocial JavaScript API. </p>
<p>To write a social application, you need the following: </p>
<ul>
    <li>Access to a container that supports the OpenSocial APIs, such as
        orkut.com. For more information, see the <a href="http://code.google.com/apis/opensocial/gettingstarted.html">Getting Started Guide</a>. </li>
    <li>A basic working knowledge of how to build gadgets. See the
        <a href="http://code.google.com/apis/gadgets/docs/dev_guide.html">Gadgets API Developer Guide</a>.</li>
    </ul>
<p>The OpenSocial API focuses on people. It lets users share their
activities with each other and access information about their friends.
There are three primary areas of functionality in the OpenSocial API:</p>
<ul>
    <li>People and relationships</li>
    <li>Persistence</li>
    <li>Activities  </li>
    </ul>
<p>Many API calls are asynchronous as they may require a server request to retrieve or
    update information. Because of this, you need to pass in a callback function that
    will be executed once the data is returned from the server.</p>
<p>For detailed information about  the classes and method in the OpenSocial JavaScript API, see the <a href="http://code.google.com/apis/opensocial/docs/0.7/reference/">API Reference</a>. </p>
<a name="Importing" id="Importing"></a><h2>Importing the OpenSocial Library</h2>
<p>To use the OpenSocial API, add the following <code>Requires</code> section to your application:</p>

<pre>&lt;ModulePrefs title="Title of Your Application"&gt;
  &lt;Require feature="opensocial-0.7"/&gt;
&lt;/ModulePrefs&gt;
</pre>
<p>For more information about the structure and contents of a gadgets XML specification, see the <a href="http://code.google.com/apis/gadgets/docs/reference.html#XML_Ref">Gadgets API Developers Guide</a>.</p>

<a name="ListFriends_Intro" id="ListFriends_Intro"></a><h2>Accessing People and Profiles </h2>
<p>Let's get started with a simple example that lists the names of your
friends. But first, it's important to understand the roles defined by
the OpenSocial API: </p>
<ul>
  <li>Viewer: the user logged into the browser. As a viewer you
    might be viewing your own page, or you might be viewing
    another user's profile.</li>
  <li>Owner: the user who owns the profile or application in question. </li>
  <li>Friends: users whom the owner or viewer has added as friends
    in the container. </li>
</ul>
<p>The "List Friends" example discussed in this section fetches the
viewer and the viewer's friends, and displays a list of the viewers
friends. It illustrates how to fetch and operate on data in an
OpenSocial application. The basic steps are as follows: </p>
<ol>
  <li>Retrieve the data.</li>

<ul>
  <li>Create a <code>DataRequest</code> by calling <code>opensocial.newDataRequest()</code>. </li>
  <li>Call <code>DataRequest.add(request)</code> once for each type of data you would like to retrieve.</li>
  <li>After you add all of the individual requests to your <code>DataRequest</code> object, call <code>DataRequest.send(callback)</code>.</li>
</ul>

  <li>Implement a callback function to process the retrieved data. </li>

<ul>
  <li>Once the server request has been
    processed, the callback function is  executed. This function takes one <code>DataResponse</code> parameter that has
    the results of the request. In "List Friends", the <code>DataResponse</code> contains the viewer and the viewer's friends. The callback function processes the data in the <code>DataResponse</code>.</li>
  </ul>
</ol>
<p>These steps are discussed in more detail below. </p>
<a name="Fetching" id="Fetching"></a>
<h3>Retrieving the Data </h3>
<p>To get information about a viewer and a list of the viewer's friends,
        you create a new <code>DataRequest</code> object and add a request to it for each type of data you want to retrieve: </p>
<pre> /**
  * Request for friend information when the page loads.
  */
  function getData() {
    var req = opensocial.newDataRequest();
    req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
    req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
    req.send(onLoadFriends);
  };
</pre>
    <p>The last parameter in the <code>newFetch*Request()</code> calls
        is a string key used to retrieve
        the data in the response.</p>
    <a name="Basic_Info" id="Basic_Info"></a>    
    <h3>Using a Callback Function to Process the Data </h3>
    <p>Let's suppose you did the example in the previous section. Now you
        want to do something with the returned data, which is of the type <code>opensocial.DataResponse</code>.
        The <code>onLoadFriends()</code> callback function  below parses the <code>DataResponse</code> it
        takes as a parameter, and displays the names of the viewer and
        the viewer's friends:</p>
    <pre> /**
  * Parses the response to the friend information request and generates
  * html to list the friends by their display name.
  *
  * @param {Object} dataResponse Friend information that was requested.
  */
  function onLoadFriends(dataResponse) {
    var viewer = dataResponse.get('viewer').getData();
    var html = 'Friends of ' + viewer.getDisplayName(); 
    html += ':&lt;br&gt;&lt;ul&gt;';
    var viewerFriends = dataResponse.get('viewerFriends').getData();
    viewerFriends.each(function(person) {
      html += '&lt;li&gt;' + person.getDisplayName() + '&lt;/li&gt;';
    });
    html += '&lt;/ul&gt;';
    document.getElementById('message').innerHTML = html;
  };</pre>
    <p>Calling <code>DataResponse.get(key)</code> with the string key
      you passed in to the <code>newFetch*Request()</code> returns a <code>ResponseItem</code>
      containing the results of the request.</p>
    <p>Calling <code>dataResponse.get(key).getData()</code> returns  the actual
      response data for a successful request. Here are response data types associated
      with common requests:</p>
    <ul>
        <li>When you request the viewer or owner, you  get an <code>opensocial.Person</code> object back.  </li>
        <li>When you request a group of friends,  you get an <code>opensocial.Collection</code> of <code>opensocial.Person</code> objects.</li>
    </ul>
    <p><code>DataResponse.get(key).hasError()</code>  returns <code>true</code> if a given request
        was unsuccessful.</p>
    
    <a name="ListFriends_Complete" id="ListFriends_Complete"></a><h3>Complete Code for List Friends </h3>
    <p>This section lists  the complete code for the "List Friends" application discussed
        above.</p>
    <p>Within an application, usually the very first thing you want to do is
    request  the data your application needs. Note that the code includes this line: </p>
    <pre>gadgets.util.registerOnLoadHandler(getData);
</pre>
<p> This registers  <code>getData()</code> as the application's onload handler, which means that the first thing the application does (through <code>getData()</code>) is to fetch the viewer and viewer friends data.   </p>
<p>Here is the complete example. It writes its output to a <code>&lt;div&gt;</code> that has the id <code>"message"</code>. </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
 &lt;ModulePrefs title="List Friends Example"&gt;
   &lt;Require feature="opensocial-0.7"/&gt;
 &lt;/ModulePrefs&gt;
 &lt;Content type="html"&gt;

 &lt;![CDATA[

 &lt;script type="text/javascript"&gt;

 /**
  * Request for friend information.
  */
  function getData() {    
    var req = opensocial.newDataRequest();
    req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
    req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
    req.send(onLoadFriends);
  };

 /**
  * Parses the response to the friend information request and generates
  * html to list the friends along with their display name.
  *
  * @param {Object} dataResponse Friend information that was requested.
  */
  function onLoadFriends(dataResponse) {
    var viewer = dataResponse.get('viewer').getData();
    var html = 'Friends of ' + viewer.getDisplayName(); 
    html += ':&lt;br&gt;&lt;ul&gt;';
    var viewerFriends = dataResponse.get('viewerFriends').getData();
    viewerFriends.each(function(person) {
      html += '&lt;li&gt;' + person.getDisplayName() + '&lt;/li&gt;';
    });
    html += '&lt;/ul&gt;';
    document.getElementById('message').innerHTML = html;
  };

  gadgets.util.registerOnLoadHandler(getData);

  &lt;/script&gt;
  &lt;div id="message"&gt; &lt;/div&gt;
  ]]&gt;
  &lt;/Content&gt;
&lt;/Module&gt;
</pre>

    
    <a name="Persistent" id="Persistent"></a><h2><sup class="changed">Updated</sup> Working with Persistent Data</h2>
    <p>The
OpenSocial API supports saving and retrieving per-user, per-application
data. In OpenSocial v0.5 and v0.6, per-application instance and global
application data were also supported, but this is removed for v0.7.</p>
    <p>This code snippet shows how to save data to the shared store: </p>
    <pre>function populateMyAppData() {
  var req = opensocial.newDataRequest();
  var data1 = Math.random() * 5;
  var data2 = Math.random() * 100;
  var data3 = new Date().getTime();
  
  req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField1", data1));
  req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField2", data2));
  req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField3", data3));
  req.send(handlePopulateMyAppData);
};<br>
</pre>
    <p>You could retrieve the data stored in the code snippet above as follows: </p>
<pre>var req = opensocial.newDataRequest();
//Request the following three app fields
var fields = [ "AppField1", "AppField2", "AppField3" ];
<strong>req.add(req.newFetchPersonAppDataRequest("VIEWER", fields), "viewer_data");</strong>
req.send(handleRequestMyData);</pre>
<p>Here is the complete code for the application. It sets some values for the viewer and then retrieves them: </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
&lt;Module&gt;
  &lt;ModulePrefs title="Data Persistence Example" &gt; 
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="html"&gt;
  &lt;![CDATA[

  &lt;script type="text/javascript"&gt; 
   gadgets.util.registerOnLoadHandler(populateMyAppData);
   var htmlout = "";
   var me = null;

   /************************************************************************
    * Set user data
    */
   function populateMyAppData() {
     var req = opensocial.newDataRequest();
     var data1 = Math.random() * 5;
     var data2 = Math.random() * 100;
     var data3 = new Date().getTime();
     htmlout += "Setting AppField1 to " + data1 + "&lt;br /&gt;";
     req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField1", data1)) + "&lt;br /&gt;";
     htmlout += "Setting AppField2 to " + data2 + "&lt;br /&gt;";
     req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField2", data2)) + "&lt;br /&gt;";
     htmlout += "Setting AppField3 to " + data3 + "&lt;br /&gt;";
     req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField3", data3)) + "&lt;br /&gt;";
     req.send(handlePopulateMyAppData, "update_appdata");
   }

   /************************************************************************
    * Handle responses from update person app data requests
    */
   function handlePopulateMyAppData(data) {
     if (data.hadError()) {
       htmlout += data.getError();
     }
     requestMyData();
   }
   
   /************************************************************************
    * Fetch app data
    */
   function requestMyData() {
     var req = opensocial.newDataRequest();
     var fields = [ "AppField1", "AppField2", "AppField3" ];
     req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), "viewer");
     req.add(req.newFetchPersonAppDataRequest("VIEWER", fields), "viewer_data");
     req.send(handleRequestMyData);
   }

   /************************************************************************
    * Handle responses from app data requests
    */
   function handleRequestMyData(data) {
     var mydata = data.get("viewer_data");
     var viewer = data.get("viewer");
     me = viewer.getData();

     if (mydata.hadError()) {
       htmlout += data.getError();
       return;
     }
     // Do something with the returned data - note the getData call
     doSomethingWithMyData(mydata.getData());
   }

   /************************************************************************
   * Operate on user data
   */
   function doSomethingWithMyData(data) {
     //Data is indexed by user id, and represents an object where keys 
     //correspond with the app data fields.
     var mydata = data[me.getId()];
     var div = document.getElementById('content_div');
     htmlout += "My AppField1 data is: " + mydata["AppField1"] + "&lt;br /&gt;";
     htmlout += "My AppField2 data is: " + mydata["AppField2"] + "&lt;br /&gt;";
     htmlout += "My AppField3 data is: " + mydata["AppField3"] + "&lt;br /&gt;";
     div.innerHTML = htmlout;
   }
   
 &lt;/script&gt;
 &lt;div id="content_div"&gt;&lt;/div&gt;
  ]]&gt; 
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<p><strong><a name="JSON_Esc" id="JSON_Esc"></a>Note:</strong> The data stored in an OpenSocial application is always a string. For most purposes,
    it is practical to make this a <a href="http://www.json.org/">JSON</a>-encoded
string. Because OpenSocial performs automatic HTML escaping of all
returned data including application data, you must unescape stringified
JSON objects in the appdata store before parsing them. For example: </p>
<pre>var unescapedString = gadgets.util.unescapeString(jsondata);&nbsp;
var obj = gadgets.json.parse(unescapedString);</pre>
<a name="Activities" id="Activities"></a><h2>Activities</h2>
    <p>The OpenSocial API lets you share activities with your friends through an activity stream. An activity stream is
        a feed in which each entry represents an action performed by the
        user. An activity could be anything from modifying an application's state to
        writing an online review for a movie. </p>
    <p>If you request HIGH activity priority, the app will ask the user
     for permission to post activities on behalf of the user if it doesn't
     already have permission. If you request LOW priority, then the call
     will do nothing if the app doesn't have permission to post.</p>
    <p>This simple example illustrates how to create an activity: </p>
    
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
&lt;Module&gt;
  &lt;ModulePrefs title="Activities - v0.7" &gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt; 
  &lt;Content type="html"&gt;
  &lt;![CDATA[ 
  &lt;div id="content_div"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;

  var div = document.getElementById('content_div');

  function postActivity(text) {  
    var params = {};  
    params[opensocial.Activity.Field.TITLE] = text;
    var activity = opensocial.newActivity(params); 
    opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, callback);
    div.innerHTML = "Activity title is: " + activity.getField(opensocial.Activity.Field.TITLE);
  };        
  
  // The parameter passed to the callback is an opensocial.ResponseItem that
  // indicates whether the activity creation request succeeded.
  function callback(status) {
    if (status.hadError())
    {
      alert("Error creating activity.");
    }
    else 
    {
      alert("Activity successfully created.");
    }
  };
  
  postActivity("This is a sample activity, created at " + new Date().toString());

  &lt;/script&gt;
  ]]&gt; 
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<a name="Container" id="Container"></a><h2><sup class="changed">Updated</sup> Interacting with the Container </h2>
<p>The OpenSocial API gives applications the ability to interact with their container in the following ways:</p>
<ul>
  <li>Applications can  navigate from one view in the container to another (for example, from a profile view to a canvas view). </li>
  <li>Applications
can query the container for information about their environment and
tailor their behavior accordingly. For example, applications can get
information about the following: <ul>
      <li>The container's  domain.</li>
      <li>Whether the container supports a particular method.</li>
      <li>What
fields the container supports for particular objects. For example, for
a Person object, a container might support "hobbies". </li>
      </ul>
  </li>
  </ul>
<a name="Nav" id="Nav"></a><h3><sup class="changed">Updated</sup> Navigating from One View to Another</h3>
<p>You can use <code>gadgets.views.requestNavigateTo</code> to take your application from one page of a container to another (for example, to link the profile to the canvas page). </p>
<p>This example shows how to use the API to navigate from one view to
another. It displays a list of links that the user can click to
navigate to the container's available views. </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;  
  &lt;ModulePrefs title="Navigating Between Views (0.7)" description="Navigates between views"&gt;    
    &lt;Require feature="opensocial-0.7" /&gt;    
    &lt;Require feature="views" /&gt;  
  &lt;/ModulePrefs&gt;  
  &lt;Content type="html"&gt;  
  &lt;![CDATA[    
  &lt;div id="main"&gt;&lt;/div&gt;    
  &lt;script type="text/javascript"&gt;

  /** 
   * Create the list of links to the other views 
   */
  function createLinks() {  
    //Get the environment, current view and an object containing the supported views  
    var env = opensocial.getEnvironment();  
    var views = gadgets.views.getSupportedViews();  
    var currentview = gadgets.views.getCurrentView();  
    var text = [ "You are currently on the ", 
        currentview.getName(), 
      " view.  Other views: " ].join("");  

    //Set up some DOM  
    var outputdom = document.getElementById("main");  
    outputdom.appendChild(document.createTextNode(text));  
    var ol = document.createElement("ol"); 
    outputdom.appendChild(ol);  
    //Iterate over each view  
    for (var viewname in views) {    
      var view = views[viewname];    
      // Make some DOM to present each link    
      var li = document.createElement("li");    
      var a = document.createElement("a");    
      ol.appendChild(li);    
      li.appendChild(a);    
      a.href = "javascript:void(0);";    
      //Put the name of the view in the link    
      a.appendChild(document.createTextNode("Link to " + view.getName()));    
      //Handle when the user clicks a link to the other server    
      a.onclick = getNavigateClosure(view);  
    }
  };
  /** 
   * Returns a function that navigates to the supplied view 
   */
    function getNavigateClosure(view) {  
      return function() { gadgets.views.requestNavigateTo(view); };
    };

  //Execute createLinks when the page is done loading
  gadgets.util.registerOnLoadHandler(createLinks);    
  &lt;/script&gt;  
  ]]&gt;  
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<p>Note this function in the above example: </p>
<pre>function getNavigateClosure(view) { 
   return function() { gadgets.views.requestNavigateTo(view); };
};</pre>
<p>It uses a technique known as a <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29">closure</a>.
In this context, it means that a function invoked from within another
function has access to the local variables of the outer function. The
use of a closure here allows the name of the selected view to be passed
into the <code>requestNavigateTo()</code> method when the user clicks the link for that view. </p>
<a name="Env" id="Env"></a><h3><sup class="changed">Updated</sup> Querying the Environment </h3>
<p>The <code>Environment</code> class includes a <code>getDomain</code> method, which tells you which site you are in (such as <code>orkut.com</code> or <code>myspace.com</code>). This allows your application to respond in different ways to different environments. The  <code>getDomain</code>
method can be helpful in building absolute URLs in cases where the API
only returns a relative URL. In general, however, we recommend that you
use another method, <code>hasCapability,</code> for all functional changes. The <code>hasCapability</code>
method takes a function name and tells you if that function is
available in your current container. This lets a container add its own
extensions to OpenSocial while still giving developers one common
mechanism for accessing them. This container-specific extensibility
also shows up in the <code>supportsField</code> method. A container
provider can add its own person or activity field. To remain compliant
with the OpenSocial spec, this field needs to be documented somewhere
outside of the <code>opensocial</code> namespace.</p>
<p>This sample application changes its display depending on whether the user is in the profile or the canvas:</p>
<pre>
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;Module&gt; 
    &lt;ModulePrefs title="My 0.7 Environment"&gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt; &lt;Content type="html"&gt;
  &lt;![CDATA[
  
  &lt;script type="text/javascript"&gt;
  /**  
   * Request for friend information when the page loads.  
   */
  function getData() {    
    var req = opensocial.newDataRequest();
    req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
    req.send(greetUser);  
  }
  
  /**  
   * Change the display of the user greeting depending on whether the
   * user is in the profile or the canvas. 
   */
  function greetUser(dataResponse) {
    var viewer = dataResponse.get('viewer').getData();
    // Determine whether the getCurrentView feature is supported
    var isAble = gadgets.util.hasFeature("gadgets.views.getCurrentView");
    var html = '&lt;h2&gt;Greetings,  ' + viewer.getDisplayName() + '!&lt;/h2&gt;';
    // If the container supports the getEnvironment method, determine whether the user
    // is in the canvas or profile
    if (isAble)
    {      
      var currView = gadgets.views.getCurrentView();
    // If the user is in the canvas, display the canvas view of the greeting 
    if (currView.getName() == 'canvas')
      {
        showCanvasView(html);
      }
    // Otherwise, display the profile view of the greeting
    else
    {
      // If the container supports the field THUMBNAIL_URL for PERSON objects,
      // include it in the profile view greeting page
      var myenv = opensocial.getEnvironment();
      if (myenv.supportsField(opensocial.Environment.ObjectType.PERSON, opensocial.Person.Field.THUMBNAIL_URL))
        {
          var thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL); 
        html += "&lt;img src=" + thumb + "/&gt;";
        }
      // Display the greeting in the profile and include the user's thumbnail
      document.getElementById('profile-div').innerHTML = html;
    }

    }
    // Default: just display the greeting with no image
    else {
      document.getElementById('profile-div').innerHTML = html;
    }
  }

  /** If the user is in canvas, change the display to take advantage of
   * additional screen area
   */
  function showCanvasView(str) {
    var div = document.getElementById('canvas-div');
    div.style.display="";
    str += "&lt;img src='http://gadget-doc-examples.googlecode.com/svn/trunk/my-canvas-photo.jpg' /&gt;";
    div.innerHTML = str;
  }
  gadgets.util.registerOnLoadHandler(getData);
  &lt;/script&gt;
  &lt;div id="profile-div"&gt; &lt;/div&gt;
  &lt;div id="canvas-div" style="display:none; font-family:Tahoma; background-color: #FFC0CB; margin: 5px; height: 570px; text-align: center;"&gt;&lt;/div&gt;

  ]]&gt;  
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<a name="Multiple_Content" id="Multiple_Content"></a>
<h3><sup class="changed">New!</sup> Including Multiple Content Sections</h3>
<p>You can include more than one <code>&lt;Content&gt;</code> section   in a gadget XML file, where each <code>&lt;Content&gt;</code> section declares the views it should be   rendered on. All <code>&lt;Content&gt;</code> sections should be siblings in the document   tree, and may use the optional parameter<code> view=</code> to define the views in   which they should render. </p>
<h4>Two content sections</h4>
<p>Here is a simple example that shows a gadget with two content sections:  </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;Module&gt;<br>&nbsp; &lt;ModulePrefs title="Multiple Content Sections (version 1)"&gt;<br>&nbsp; &nbsp; &lt;Require feature="opensocial-0.7" /&gt;<br>&nbsp; &lt;/ModulePrefs&gt;<br>&nbsp; &lt;Content type="html" view="profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Profile&lt;/h1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&nbsp; &lt;Content type="html" view="canvas"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Canvas&lt;/h1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&lt;/Module&gt;</pre>
<p>The  output is as follows: </p>
<p><strong>Profile view</strong> </p>
<pre>&lt;h1&gt;Profile&lt;/h1&gt;</pre>
<p><strong>Canvas view</strong> </p>
<pre>&lt;h1&gt;Canvas&lt;/h1&gt;</pre>
<p><strong>Any other views that are not canvas or profile</strong> </p>
<p><em>no content is displayed</em> </p>
<h4>Content sections with   multiple views specified</h4>
<p>Content sections can specify multiple views, separated by commas: </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;Module&gt;<br>&nbsp; &lt;ModulePrefs title="Multiple Content Sections (version 2)"&gt;<br>&nbsp; &nbsp; &lt;Require feature="opensocial-0.7" /&gt;<br>&nbsp; &lt;/ModulePrefs&gt;<br>&nbsp; &lt;Content type="html" view="canvas,profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Canvas and Profile&lt;/h1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&lt;/Module&gt;</pre>
<p>The output is as follows: </p>
<p><strong>Profile view</strong> </p>
<pre>&lt;h1&gt;Canvas and Profile&lt;/h1&gt;</pre>
<p><strong>Canvas view</strong> </p>
<pre>&lt;h1&gt;Canvas and Profile&lt;/h1&gt;</pre>
<p><strong>Any other views that are not canvas or profile</strong> </p>
<p><em>no content is displayed</em> </p>
<h4>Content   section with view specified and no default content section</h4>
<p>If you specify a content section with a view parameter, that content
section is only shown on that view. If you don't specify a default
content section, other views will not display any content. </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;Module&gt; &nbsp;<br>&nbsp; &lt;ModulePrefs title="Multiple Content Sections (version 3)"&gt;<br>&nbsp; &nbsp; &lt;Require feature="opensocial-0.7" /&gt;<br>&nbsp; &lt;/ModulePrefs&gt;<br>&nbsp; &lt;Content type="html" view="profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Profile&lt;/h1&gt;<br>&nbsp; ]]&gt; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &lt;/Content&gt;<br>&lt;/Module&gt;</pre>
<p>The output is as follows: </p>
<p><strong>Profile view</strong> </p>
<pre>&lt;h1&gt;Profile&lt;/h1&gt;</pre>
<p><strong>Canvas view</strong> </p>
<p><em>no content is displayed</em> </p>
<p><strong>Any other views that are not canvas or profile</strong> </p>
<p><em>no content is displayed</em> </p>
<h4>Content   section with view specified and a default content section</h4>
<p>To specify a default content section, simply define a content section with no   view parameter:</p>
<pre>&lt;Module&gt; &nbsp;<br>&nbsp; &lt;ModulePrefs title="Multiple Content Sections (version 4)"&gt;<br>&nbsp; &nbsp; &lt;Require feature="opensocial-0.7" /&gt;<br>&nbsp; &lt;/ModulePrefs&gt;<br>&nbsp; &lt;Content type="html" view="profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Profile&lt;/h1&gt;<br>&nbsp; ]]&gt; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &lt;/Content&gt;<br>&nbsp; &lt;Content type="html"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Default&lt;/1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&lt;/Module&gt;</pre>
<p>The output is as follows:</p>
<p><strong>Profile view</strong> </p>
<pre>&lt;h1&gt;Profile&lt;/h1&gt;</pre>
<p><strong>Canvas view</strong> </p>
<pre>&lt;h1&gt;Default&lt;/h1&gt;</pre>
<p><strong>Any other views that are not canvas or profile</strong> </p>
<pre>&lt;h1&gt;Default&lt;/h1&gt;</pre>
<h4>Complete Example</h4>
<p>You can use all of these techniques in one gadget: </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;Module&gt;<br>&nbsp; &lt;ModulePrefs title="Multiple Content Sections (version 5)"&gt;<br>&nbsp; &nbsp; &lt;Require feature="opensocial-0.7" /&gt;<br>&nbsp; &lt;/ModulePrefs&gt;<br>&nbsp; &lt;Content type="html" view="profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Profile&lt;/h1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&nbsp; &lt;Content type="html" view="canvas"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Canvas&lt;/h1&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&nbsp; &lt;Content type="html" view="canvas,profile"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h2&gt;This shows up in canvas and profile views&lt;/h2&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&nbsp; &lt;Content type="html"&gt;<br>&nbsp; &lt;![CDATA[<br>&nbsp; &nbsp; &lt;h1&gt;Default&lt;/h1&gt;<br>&nbsp; &nbsp; &lt;h2&gt;The content in this section only shows up if no other content sections are applicable&lt;/h2&gt;<br>&nbsp; ]]&gt;<br>&nbsp; &lt;/Content&gt;<br>&lt;/Module&gt;</pre>
<p>The output is as follows:</p>
<p><strong>Profile view</strong> </p>
<pre>&lt;h1&gt;Profile&lt;/h1&gt;<br>&lt;h2&gt;This shows up in canvas and profile views&lt;/h2&gt;</pre>
<p><strong>Canvas view</strong> </p>
<pre>&lt;h1&gt;Canvas&lt;/h1&gt;<br>&lt;h2&gt;This shows up in canvas and profile views&lt;/h2&gt;</pre>
<p><strong>Any other views that are not canvas or profile</strong> </p>
<pre>&lt;h1&gt;Default&lt;/h1&gt;<br>&lt;h2&gt;The content in this section only shows up if no other content sections are applicable&lt;/h2&gt;</pre>

<a name="Remote_Content" id="Remote_Content"></a><h2><sup class="changed">Updated</sup> Fetching Remote Content</h2>
<p>You can use the <code>gadgets.io.makeRequest()</code> method to  remotely fetch content from other web servers and web pages. In an enhancement to the old gadget API <a href="http://code.google.com/apis/gadgets/docs/remote-content.html"><code>IG_Fetch...</code></a> methods, <code>gadgets.io.makeRequest()</code>  allows for POSTs as well as GETs, and you can specify whether you want your request to be signed or even authenticated.</p>
<p>The <code>gadgets.io.makeRequest()</code> method takes these parameters:</p>
<ul>
  <li>The URL from which to fetch remote content.</li>
  <li>A callback function that processes the fetched content. </li>
  <li>Parameters
that specify additional information about how the content is being
fetched, what type of content it is, how the content should be
displayed, and so on.</li>
  </ul>
<p>By default, <code>makeRequest()</code> uses the GET method to fetch data, and the default type for content is <code>TEXT</code> (where a web page's content is fetched as raw text).  </p>
<p>This example shows a very simple use of the API. It  fetches the first 400 characters on <code>www.google.com</code> and outputs them to a <code>&lt;div&gt;</code>:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="Fetch Content as Text"&gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="html"&gt;
  &lt;![CDATA[
    &lt;div id="content_div"&gt;&lt;/div&gt;
    &lt;script type="text/javascript"&gt;

    function makeNormalRequest() {    
      var params = {};  
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;  
      var url = "http://www.google.com";  
      gadgets.io.makeRequest(url, response, params);
    };

    function response(obj) {  
      //obj.text contains the text of the page that was requested  
      var str = obj.text;
      var html =  str.substr(0,400);  
      document.getElementById('content_div').innerHTML = html;
    };

    makeNormalRequest();
    &lt;/script&gt;
  ]]&gt;
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<a name="Caching" id="Caching"></a>
<h3><sup class="changed">New!</sup> Caching</h3>
<p>Calls to <code>makeRequest</code> are cached by default. In the example below, the wrapper function takes the same   parameters as the <code>makeRequest</code> call, but accepts another parameter named   <code>refreshInterval</code>,
which allows you to specify the cache duration. However, caching serves
a useful purpose, and you should be careful not to refresh the cache so
often that you degrade performance. Caching makes fetching data faster.
It also reduces the load on third-party servers hosting the remote
content. You should try to avoid disabling the cache completely, which
you would do by specifying 0. For more discussion of this topic, see
the <a href="http://code.google.com/apis/gadgets/docs/remote-content.html#Params">Gadgets API Developers Guide</a>. </p>
<pre>function makeCachedRequest(url, callback, params, refreshInterval) {<br>&nbsp; var ts = new Date().getTime();<br>&nbsp; var sep = "?";<br>&nbsp; if (refreshInterval &amp;&amp; refreshInterval &gt; 0) {<br>&nbsp; &nbsp; ts = Math.floor(ts / (refreshInterval * 1000));<br>&nbsp; }<br>&nbsp; if (url.indexOf("?") &gt; -1) {<br>&nbsp; &nbsp; sep = "&amp;";<br>&nbsp; }<br>&nbsp; url = [ url, sep, "nocache=", ts ].join("");<br>&nbsp; gadgets.io.makeRequest(url, response, params);<br>}</pre>
<p><a name="XML" id="XML"></a></p>
<h3><sup class="changed">Updated</sup> XML Example</h3>
<p>This example shows how to use the <code>DOM</code> content type to process XML data. When you specify the <code>DOM</code> content type, <code>makeRequest()</code>
retrieves the specified XML document as a DOM object. Once you have the
object, you can operate on it using standard DOM JavaScript functions.
For more discussion of this topic, see the <a href="http://code.google.com/apis/gadgets/docs/remote-content.html#Fetch_XML">Gadgets API Developers Guide</a>. </p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="Fetch XML"&gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="html"&gt;
  &lt;![CDATA[
    &lt;div id="content_div"&gt;&lt;/div&gt;
    &lt;script type="text/javascript"&gt;

    function makeDOMRequest() {    
      var params = {};  
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM;  
      var url = "http://doc.examples.googlepages.com/breakfast-data.xml";  
      gadgets.io.makeRequest(url, response, params);
    };

    function response(obj) { 
      // obj.data contains a Document DOM element corresponding to the
      // page that was requested
      var domdata = obj.data;
      var title = domdata.getElementsByTagName("menu").item(0).getAttribute("title");
      var html = "&lt;h2&gt;" + title + "&lt;/h2&gt;";
      
      // Get a list of the &lt;food&gt; element nodes in the file
      var itemList = domdata.getElementsByTagName("food");
 
      // Loop through all &lt;food&gt; nodes
      for (var i = 0; i &lt; itemList.length ; i++) { 
        // For each &lt;food&gt; node, get child nodes.
        var nodeList = itemList.item(i).childNodes;

        // Loop through child nodes. Extract data from the text nodes that are
        // the children of the associated name, price, and calories element nodes.
        for (var j = 0; j &lt; nodeList.length ; j++) {
          var node = nodeList.item(j);
          if (node.nodeName == "name") {
            var name = node.firstChild.nodeValue;
          }
          if (node.nodeName == "price") {
            var price = node.firstChild.nodeValue;
          }
        }
        html += name + " - ";
        html += price + "&lt;br /&gt;";
      }
      html += "&lt;/div&gt;";
      document.getElementById('content_div').innerHTML = html;
    };
    makeDOMRequest();
    &lt;/script&gt;
  ]]&gt;
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<a name="JSON" id="JSON"></a>
<h3><sup class="changed">New!</sup> JSON Example</h3>
<p>You can use the <code>JSON</code> content type to fetch JSON-encoded content as a JavaScript object. </p>
<p>The application below fetches content from a sample PHP page that contains the following JSON-encoded string: </p>
<pre id="line1">{"validated":"This request was spoofed","query":[],"url":"http:\/\/graargh.returnstrue.com\/buh\/fetchme.php","signature":"","signature_len":1}</pre>
<p>When you fetch content from the PHP page that contains this string,
the return value is a JavaScript object containing key-value pairs
(that is, an associative array). This sample retrieves the object and
then prints out the key-value pairs it contains:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="Fetch JSON 8"&gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="html"&gt;
  &lt;![CDATA[
    &lt;div id="content_div"&gt;&lt;/div&gt;
    &lt;script type="text/javascript"&gt;

    function makeJSONRequest() {    
      var params = {};
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
      // This URL returns a JSON-encoded string that represents a JavaScript object
      var url = "http://graargh.returnstrue.com/buh/fetchme.php";
      gadgets.io.makeRequest(url, response, params);
    };

    function response(obj) { 
      var jsondata = obj.data;
      var html = "&lt;strong&gt;Values: &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;";
      // Returned JS object can be processed as an associative array
      for (var key in jsondata) {    
        var item = jsondata[key];
        html += key + ": ";
        html += item + "&lt;br /&gt;";
      }	   	    
      document.getElementById('content_div').innerHTML = html;
     };
     makeJSONRequest();
     &lt;/script&gt;
  ]]&gt;
  &lt;/Content&gt;
&lt;/Module&gt;</pre>

<h4><sup class="changed">New!</sup> More about JSON </h4>
<p><a href="http://www.json.org/">JSON</a> (JavaScript Object Notation)
is a data interchange format lets you encode certain types of objects
(arrays and collections of key-value pairs) as strings that can easily
be passed around. </p>
<p>The Gadgets API  provides the <code>gadgets.json.stringify()</code> method for encoding object as JSON strings, and the <code>gadgets.json.parse()</code>
method for turning a JSON string into an object. Note that because
OpenSocial performs automatic HTML escaping of all returned data
including application data, you must unescape stringified JSON objects
in the appdata store before parsing them, for example: <code>gadgets.util.unescapeString(jsondata)</code>.</p>
<p>This example creates a JavaScript array, encodes it as a JSON
string, and then converts the JSON string back into an Array object:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="JSON Example"&gt;
    &lt;Require feature="opensocial-0.7"/&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="html"&gt;
  &lt;![CDATA[
     &lt;div id="content_div"&gt;&lt;/div&gt;
     &lt;script type="text/javascript"&gt;
     var html = "";
     // Create Array object
     var myfriends = new Array();
     myfriends[0] = "Touki";
     myfriends[1] = "Rowan";
     myfriends[2] = "Trevor";

     // Encode array as JSON string
     var jsonString = toJSON(myfriends);
     html += "The JSON string is " + jsonString + "&lt;br /&gt;";
     html += "The type of jsonString is " + typeof(jsonString) + "&lt;br /&gt;";

     // Convert JSON string back to an object
     var arr_obj = toObject(jsonString);
     html += "The type of arr_obj is " + typeof(arr_obj);
     document.getElementById('content_div').innerHTML = html;

     // Encode object as JSON string
     function toJSON(obj) { 
       return gadgets.json.stringify(obj); 
     }

     // Convert JSON string into an object
     function toObject(str) {
       return gadgets.json.parse(str);
    }
    &lt;/script&gt;
  ]]&gt;
  &lt;/Content&gt;
&lt;/Module&gt;</pre>
<p>The output from this gadget is as follows:</p>
<pre>The JSON string is ["Touki","Rowan","Trevor"]
The type of jsonString is string
The type of arr_obj is object
</pre>
<a name="POST" id="POST"></a>
<h3><sup class="changed">Updated</sup> Using the POST Method</h3>
<p>By default, remote content is fetched using the GET method. You can use the <code>POST_DATA</code> parameter to use the POST method to fetch content instead. For example:</p>
<pre>function makePOSTRequest() {<br>&nbsp; var params = {};<br>&nbsp; var postdata = {<br>&nbsp; &nbsp; data1 : "test",<br>&nbsp; &nbsp; data2 : 1234566<br>&nbsp; };<br>&nbsp; params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;<br>&nbsp; params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);<br>&nbsp; var url = "http://graargh.returnstrue.com/buh/makerequest.php";<br>&nbsp; gadgets.io.makeRequest(url, response, params);<br>};<br><br>function response(obj) {<br>&nbsp; // do something<br>};<br><br>makePOSTRequest(); </pre>
<a name="Auth" id="Auth"></a>
<h3><sup class="changed">Updated</sup> Setting an Authorization Type </h3>
<p>The Gadgets API supports the following authorization types:  </p>
 <ul>
   <li><code>gadgets.io.AuthorizationType.AUTHENTICATED</code> (container uses full authentication) </li>
   <li><code>gadgets.io.AuthorizationType.SIGNED</code> (request is signed by the container) </li>
   <li><code>gadgets.io.AuthorizationType.NONE</code> (the default) </li>
   </ul>
 <p>How you use these methods depends on your container. Here is one <a href="http://code.google.com/p/opensocial-resources/wiki/OrkutValidatingSignedRequests">example</a> of using a signed authorization type that is specific to Orkut. </p>
 <a name="Permission" id="Permission"></a><h2><sup class="changed">Updated</sup> Permission Control</h2>
<p>The OpenSocial API supports permission control in applications. When
an application uses a data request to fetch a viewer from the server,
it is only returned if that application has access. If the application
does not have access, one of the standard error codes, <code>opensocial.ResponseItem.Error.UNAUTHORIZED</code>, is returned instead. An application can also check ahead of time for its access by using the new <code>opensocial.hasPermission</code> call. If access is denied, you can use <code>opensocial.requestPermission</code>
to ask the viewer for the specified permission. Of course, some
containers may always grant viewer access, and some may always deny,
but this decision is up to the container.</p>
<p>This excerpt illustrates how to use the permission control API:</p>
<pre>/**
 * Request the VIEWER and OWNER objects
 */
function requestData() {
  var req = opensocial.newDataRequest();
  req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), "owner");
  
  // If we have permission to see the viewer's info, then add it to the request.
  if (opensocial.hasPermission(opensocial.Permission.VIEWER)) {
    req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), "viewer");
  }
  req.send(showData);
}

function showData(data) {
  var viewer = data.get("viewer").getData();
  var owner = data.get("owner").getData();
  var ownerOutput = document.getElementById("owner-output");
  var viewerOutput = document.getElementById("viewer-output");

  showPerson(owner, ownerOutput);
  if (opensocial.hasPermission(opensocial.Permission.VIEWER)) {
    showPerson(viewer, viewerOutput);
  }
}

function requestPermission() {
  var reason = "To demonstrate permission capabilities";
  opensocial.requestPermission(opensocial.Permission.VIEWER, reason, requestData);
}

function showPerson(person, div) {
  var name = person.getDisplayName();
  var thumb = person.getField(opensocial.Person.Field.THUMBNAIL_URL);
  var html = '&lt;img src="' + thumb + '"/&gt;' + name; 
  div.innerHTML = html;
}

//Execute requestData when the page is done loading
gadgets.util.registerOnLoadHandler(requestData);
</pre>

    <a name="Learn" id="Learn"></a><h2>To Learn More </h2>
    <p>To learn more about the OpenSocial API, here are some additional resources:</p>
    <ul>
      <li>For more code samples and tutorials, see the OpenSocial <a href="http://code.google.com/apis/opensocial/articles/">Articles and Tutorials</a></li>
      <li>For reference information, see the <a href="http://code.google.com/apis/opensocial/docs/0.6/reference/">OpenSocial JavaScript API Reference</a> </li>
      <li> If you're developing an application specifically
      for Orkut, check out the <a href="http://code.google.com/apis/orkut/">Orkut Developer Home</a></li>
      <li>Finally, be sure to visit the <a href="http://groups.google.com/group/opensocial">Developer Forum</a> </li>
    </ul>
    <p class="backtotop"><a href="#top">Back to top</a></p>

<!-- ########## END PAGE CONTENT ########## -->
  
   
      <div style="height: 17353px;" id="gc-collapsible"></div></div><!-- end gc-pagecontent -->
   </div><!-- end gooey wrapper -->

    </div> <!-- end codesite content -->

<div id="gc-footer" dir="ltr"> 
  <div class="text">
    
      <div class="notice"><div id="notice" style="text-align: center;">
  Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
  the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
  Attribution 2.5 License</a>.
<!-- <rdf:RDF xmlns="http://web.resource.org/cc/" 
              xmlns:dc="http://purl.org/dc/elements/1.1/"
              xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <Work rdf:about="">
    <license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
  </Work>
  <License rdf:about="http://creativecommons.org/licenses/by/2.5/">
    <permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
    <permits rdf:resource="http://web.resource.org/cc/Distribution"/>
    <requires rdf:resource="http://web.resource.org/cc/Notice"/>
    <requires rdf:resource="http://web.resource.org/cc/Attribution"/>
    <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
  </License>
</rdf:RDF> -->
</div>
</div>
    
    ©2008 Google -
    <a href="http://code.google.com/">Code Home</a> -
    <a href="http://www.google.com/accounts/TOS">Site Terms of Service</a> -
    <a href="http://www.google.com/privacy.html">Privacy Policy</a> -
    <a href="http://code.google.com/more/">Site Directory</a>
     <br>
     <br>
    Google Code offered in:  
    <a href="http://code.google.com/intl/zh-CN/">中文</a> - 
    <a href="http://code.google.com/">English</a> - 
    <a href="http://code.google.com/intl/pt-BR/">Português</a> - 
    <a href="http://code.google.com/intl/ru/">Pусский</a> - 
    <a href="http://code.google.com/intl/es/">Español</a> - 
    <a href="http://code.google.com/intl/ja/">日本語</a> </div><!-- end gc-footer -->
  </div>
</div><!-- end gc-containter -->
<script src="devguide_files/ga.js" type="text/javascript">
</script>
<script type="text/javascript">
  try {
    var pageTracker = _gat._getTracker("UA-18071-1");
    pageTracker._setAllowAnchor(true);
    pageTracker._initData();
    pageTracker._trackPageview(); 
  } catch(e) {}
</script>




  <select size="6" style="position: absolute; display: none;" class="fauxSelect"><option value="zh-CN">中文 (简体)</option><option value="en">English</option><option value="pt-BR">Português (Brasil)</option><option value="ru">Pусский</option><option value="es">Español</option><option value="ja">日本語</option></select><div id="gc-collapsible-arrow"></div><div id="cs-searchresults"><div id="cs-recommended">Suggestions</div><div id="searchResult1"></div><div id="searchResult2"></div><div id="searchResult3"></div><div id="searchResult4"></div><div id="searchResult5"></div><div id="searchResult6"></div><div id="searchResult7"></div></div></body></html>